<?php

declare(strict_types=1);

namespace App\Model;


/**
 * @property int $id
 * @property string $name
 * @property string $type
 * @property int $status
 * @property string $remark
 * @property string $create_time
 * @property string $update_time
 * @property int $sort
 */
class Dict extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'dict';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['name', 'type', 'status', 'remark', 'sort'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'status' => 'integer', 'sort' => 'integer'];

    public function dictData()
    {
        return $this->hasMany(DictDatum::class, 'dict_id', 'id');
    }

    // 如果你需要隐藏原始的 create_time 字段
    protected array $hidden = ['create_time', 'update_time'];

    // 如果你需要显示新的 createTime 字段
    protected array $appends = ['createTime', 'updateTime'];

    public function getCreateTimeAttribute()
    {
        return $this->attributes['create_time'];
    }

    public function getUpdateTimeAttribute()
    {
        return $this->attributes['update_time'];
    }

}
